<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link href="{{url_for('static', filename='css/bootstrap.min.css')}}" rel="stylesheet">
    <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
    <title>查询提交关键词链接</title>
    <style>
        .my-h1 {
            margin-bottom: 3rem!important;
            margin-top: 2rem!important;
            font-size: 42px;
            text-align: center;
        }
        </style>
</head>
<body>
    <div class="container">
        <h1 class="my-h1">查询提交关键词链接</h1>
        <form id="myForm" method="post">
            <div class="row">
                <div class="col-md-3 form-group">
                    <select class="form-control" id="grade" name="grade">
                        <option value="">请选择年级</option>
                        {% for grade in grade_options %}
                            <option value="{{ grade }}" {% if grade == selected_grade %}selected{% endif %}>{{ grade }}</option>
                        {% endfor %}
                    </select>
                </div>
                <div class="col-md-3 form-group">
                    <select class="form-control" id="lesson" name="lesson">
                        <option value="">请选择课程</option>
                        {% for lesson in lesson_options %}
                            <option value="{{ lesson }}" {% if lesson == selected_lesson %}selected{% endif %}>{{ lesson }}</option>
                        {% endfor %}
                    </select>
                </div>
                <div class="col-md-3 form-group">
                    <button type="submit" class="btn btn-primary">查询</button>
                </div>
            </div>
        </form>
        <hr>
        <div class="row mt-4">
            {% if submit_url %}
                <a href="{{ submit_url }}" class="text-primary" style="font-size: 1.5rem;" target="_blank">{{ submit_url }}</a>
            {% endif %}
        </div>
    </div>

    <script>
        document.getElementById('myForm').addEventListener('submit', function(e) {
            var grade = document.getElementById('grade').value;
            var lesson = document.getElementById('lesson').value;
            if (grade === '' || lesson === '') {
                alert('请选择年级和第几课');
                e.preventDefault();
            }
        });
    </script>
</body>
</html>